package com.viphuli.app.tool.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;

import com.loopj.android.http.RequestParams;
import com.viphuli.app.tool.R;
import com.viphuli.app.tool.common.AccessTokenKeeper;
import com.viphuli.app.tool.common.MyPageHelper;
import com.viphuli.app.tool.handler.MyBaseHttpResponseHandler.HandlerType;
import com.viphuli.app.tool.http.ApiRequest;

/**
 * 更改圈子名称
 * 
 * @author li.li
 *
 */
public class UpdateCircleNameFragment extends UpdateInfoFragment{
	

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		if (R.id.id_menu_update_info_right == item.getItemId()) {

			AccessTokenKeeper tokenKeeper = AccessTokenKeeper.readAccessToken(getActivity());

			if (tokenKeeper.isLogin()) {
				
				String hospital = args.getString("hospital");
				String department = args.getString("department");

				RequestParams params = new RequestParams();
				params.put("uid", tokenKeeper.getOpenId());
				params.put("name", contentText.getText().toString());
				params.put("circle_id", tokenKeeper.getUser().circleId());
				params.put("hospital", hospital);
				params.put("department", department);

				ApiRequest.circleInfoChange.request(this, params, HandlerType.waitting);

			}

			return true;
		}

		return false;
	}

	public static void go(Activity act, String title, String content,String hospital, String department) {

		Bundle args = new Bundle();
		args.putString("content", content);
		args.putString("hospital", hospital);
		args.putString("department", department);

		MyPageHelper.updateCircleName.showMyPage(act, args, title);

	}

}
